<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>取反</title>
</head>

<body>
  <div id="box">
    {{text}}
    <br>
    <ul v-html="arr.join('')" @click='del'>
    </ul>
    <button @click="addrandom">生成</button>
  </div>
  <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.14/vue.js"></script>
  <script>
    new Vue({
      el: '#box',
      data: {
        text: 'Hello,World',
        list: '',
        arr: []
      },
      methods: {
        addrandom() {
          let random = parseInt(Math.random() * 20)
          console.log(random);
          this.arr.push("<li>" + random + "<button>删除</button>" + "</li>")
          console.log(this.arr);
        },
        del(e) {
          console.log(e.target.parentNode);
          this.arr.forEach((item, index) => {
            // console.log(item);
            // if (e.target.parentNode == item) {
            //   console.log(1);
            // }
          })
        }
      }
    })

  </script>
</body>

</html>